﻿#pragma once
 #include "Ogre.h"
 #include "OgreStringConverter.h"
 #include "OgreException.h"

_NAMESPACE_BEGIN

using namespace Ogre;

class OGREFrameListener: public FrameListener, public WindowEventListener
{
public:
	/// 构造方法需要一个RenderWindow，因为它将决定输入上下文
	OGREFrameListener(RenderWindow* win, Camera* cam, bool bufferedKeys = true, bool bufferedMouse = true,
		bool bufferedJoy = true );

	/// 调整鼠标限制移动区域
	virtual void windowResized(RenderWindow* rw);

	/// 在窗口关闭之前独立OIS（在Linux环境下非常重要）
	virtual void windowClosed(RenderWindow* rw);

	virtual ~OGREFrameListener();

	/// 重写frameRenderingQueued(不要考虑frameEnded)
	/// 该方法发生在所有渲染目标都获得了渲染命令之后，渲染窗口双缓冲翻页之前
	bool frameRenderingQueued(const FrameEvent& evt);

	bool frameEnded(const FrameEvent& evt);

protected:
	Camera* mCamera;

	Vector3 mTranslateVector;
	Real mCurrentSpeed;
	RenderWindow* mWindow;
	bool mStatsOn;

	std::string mDebugText;

	unsigned int mNumScreenShots;
	float mMoveScale;
	float mSpeedLimit;
	Degree mRotScale;
	// just to stop toggles flipping too fast
	Real mTimeUntilNextToggle ;

	TextureFilterOptions mFiltering;
	int mAniso;

	int mSceneDetailIndex ;
	Real mMoveSpeed;
	Degree mRotateSpeed;
	Overlay* mDebugOverlay;

public:

	/// OIS 输入设备
	OIS::InputManager* mInputManager;
	OIS::Mouse*    mMouse;
	OIS::Keyboard* mKeyboard;
	OIS::JoyStick* mJoy;
};

_NAMESPACE_END